Learn R Programming

hablar (version 0.3.2)

n_unique count unique elements: n_unique

Description

Simple wrapper for length(unique(.x)). If you use n_unique_(.x) then NA is ignored when counting.

Usage

n_unique(.x, ignore_na = FALSE)

n_unique_(.x, ignore_na = TRUE)

n_unique_(.x, ignore_na = TRUE)

Value

a single numeric vector of the same length as the data frame it is applied to.

Arguments

.x

a vector

ignore_na

a logical indicating whether missing values should be removed

See Also

vignette("s"), vignette("hablar")

Examples

Run this code

# Simple
n_unique(c(1, 2, 2, 3))

# Same result as above eventhough vector includes NA
n_unique_(c(1, 2, 2, 3, NA))

Run the code above in your browser using DataLab